package com.chen.webservice.exception;


/**
 * <p>
 *     <br/>业务异常
 * </p>
 * @author daijiang@hopechart.com
 * @date 2018-01-24 14:55:58
 * @copyright 杭州鸿泉物联网技术股份有限公司
 * @version V1.0.0
 */
@SuppressWarnings("serial")
public class ServiceException extends RuntimeException{

    protected Object[] args;
    protected ErrorCode errorCode;

    public Object[] getArgs() {
        return args;
    }

    public ErrorCode getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(ErrorCode errorCode) {
        this.errorCode = errorCode;
    }

    public ServiceException() {
        super();
    }

    public ServiceException(String message) {
        super(message);
        this.args = new Object[]{message};
        this.errorCode = ErrorCode.BUSINESS_ERROR_CUST;
    }

    public ServiceException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
        this.args = new Object[]{errorCode.getMessage()};
    }

    public ServiceException(ErrorCode errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
        this.args = new Object[]{message};
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
    }

    public ServiceException(ErrorCode errorCode, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = errorCode;
    }

    public ServiceException(Throwable cause) {
        super(cause);
    }

    public ServiceException(ErrorCode errorCode, Throwable cause) {
        super(cause);
    }

    protected ServiceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    protected ServiceException(ErrorCode errorCode, String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.errorCode = errorCode;
    }
}
